<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master"
  AutoEventWireup="true" CodeBehind="NewsList.aspx.cs" Inherits="ITViet.Web.Admin.NewsList" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPager" TagPrefix="dxpg" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div>
    <table>
      <tr>
        <td>
          <asp:Label ID="Label1" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, FromDate %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxDateEdit ID="dexFromDate" ClientInstanceName="dexFromDate" runat="server"
            AllowNull="False">
            <ValidationSettings>
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
              <ErrorImage Height="14px" />
            </ValidationSettings>
            <CalendarProperties>
              <PrevYearImage Height="19px" />
              <PrevMonthImage Height="19px" />
              <NextMonthImage Height="19px" />
              <NextYearImage Height="19px" />
              <HeaderStyle Spacing="1px" />
              <FooterStyle Spacing="4px" />
            </CalendarProperties>
          </dxe:ASPxDateEdit>
        </td>
        <td width="9" width="30px">
        </td>
        <td>
          <asp:Label ID="Label2" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, ToDate %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxDateEdit ID="dexToDate" ClientInstanceName="dexToDate" runat="server" AllowNull="False">
            <ValidationSettings>
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
              <ErrorImage Height="14px" />
            </ValidationSettings>
            <CalendarProperties>
              <PrevYearImage Height="19px" />
              <PrevMonthImage Height="19px" />
              <NextMonthImage Height="19px" />
              <NextYearImage Height="19px" />
              <HeaderStyle Spacing="1px" />
              <FooterStyle Spacing="4px" />
            </CalendarProperties>
          </dxe:ASPxDateEdit>
        </td>
        <td style="padding-left: 10px;">
          <dxe:ASPxCheckBox ID="ckbHotNews" ClientInstanceName="ckbHotNews" runat="server"
            Text="<%$ Resources:Strings, HotNews %>" Height="16px">
          </dxe:ASPxCheckBox>
        </td>
        <td style="padding-left: 5px;">
          <dxe:ASPxButton ID="btnSearch" runat="server" Text="<%$ Resources:Strings, Search %>"
            ClientInstanceName="btnSearch" OnClick="btnSearch_Click">
          </dxe:ASPxButton>
        </td>
      </tr>
      <tr>
        <td>
          <asp:Label ID="Label3" CssClass="CommonFont" runat="server" Text="<%$Resources:Strings, Status %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxComboBox ID="cbxStatus" ClientInstanceName="cbxStatus" runat="server" DataSourceID="xdsStatus"
            TextField="Value" ValueField="Id" ValueType="System.String">
            <ButtonStyle Width="11px">
            </ButtonStyle>
            <ItemStyle Font-Size="11pt" />
            <ValidationSettings>
              <ErrorImage Height="14px" Width="14px" />
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
            </ValidationSettings>
          </dxe:ASPxComboBox>
        </td>
        <td>
        </td>
        <td>
          &nbsp;<asp:Label ID="Label4" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, Language %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxComboBox ID="cbxLanguage" ClientInstanceName="cbxLanguage" runat="server"
            DataSourceID="xdsLanguage" TextField="Value" ValueField="Id" ValueType="System.Int32">
            <ButtonStyle Width="11px">
            </ButtonStyle>
            <ItemStyle Font-Size="11pt" />
            <ValidationSettings>
              <ErrorImage Height="14px" />
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
            </ValidationSettings>
          </dxe:ASPxComboBox>
        </td>
      </tr>
      <tr>
        <td>
          <asp:Label ID="Label5" CssClass="CommonFont" runat="server" Text="<%$Resources:Strings, NewsCategory %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxComboBox ID="cbxCategory" ClientInstanceName="cbxCategory" runat="server"
            TextField="Name" ValueField="Id">
            <ButtonStyle Width="11px">
            </ButtonStyle>
            <ItemStyle Font-Size="11pt" />
            <ValidationSettings>
              <ErrorImage Height="14px" Width="14px" />
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
            </ValidationSettings>
          </dxe:ASPxComboBox>
        </td>
        <td>
        </td>
      </tr>
    </table>
  </div>
  <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
  </div>
  <div style="padding-top: 20px;" class="CommonFont">
    <asp:UpdatePanel ID="updatePanel" runat="server" EnableViewState="False">
      <ContentTemplate>
        <asp:Repeater ID="rptNews" runat="server">
          <ItemTemplate>
            <div class="news">
              <div class="news_title">
                <a href='NewsDetail.aspx?t=<%# Eval("Type") %>&tid=<%#Eval("CategoryId") %>&id=<%#Eval("Id") %>'>
                  <%#Eval("Title") %>
                </a>
                <p style="width: 100%; height: auto; overflow: hidden;">
                  <span class="news_date">(<%# FormatDate(Eval("PostDate"), "dd/MM/yyyy HH:mm:ss")%>,
                  </span><span style="padding-left: 3px;">
                    <dxe:ASPxLabel ID="ASPxLabel8" runat="server" Text="<%$ Resources:Strings, PageView%>">
                    </dxe:ASPxLabel>
                  </span><span class="news_date">:
                    <%#Eval("ViewCount") %>) </span>
                </p>
              </div>
              <div style="clear: both; float: left;" class="news_img">
                <img alt="" src='<%#Eval("ImagePath")%>'> </img>
              </div>
              <div style="float: left; padding-left: 5px;" class="news_summary">
                <%#Eval("Summary")%>
              </div>
              <div class="news_link">
                <%if (CanDelete)
                  { %>
                <a href='javascript:onDelete(<%#Eval("Id")%>);void 0;'>
                  <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Strings, Delete%>"></asp:Literal>
                </a>&nbsp;
                <%}
                  if (CanModify)
                  { %>
                <a href='NewsDetail.aspx?t=<%# Eval("Type") %>&tid=<%#Eval("CategoryId") %>&Id=<%#Eval("Id") %>'
                  style="">
                  <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:Strings, Edit%>"></asp:Literal>
                </a>
                <%} %>
              </div>
            </div>
            <div style="clear: both; border-bottom: dotted 1px grey; padding-top: 8px;">
            </div>
          </ItemTemplate>
        </asp:Repeater>
        <div style="float: right; padding-top: 10px;">
          <dxpg:ASPxPager ID="pager" runat="server" CurrentPageNumberFormat="{0}" OnPageIndexChanged="pager_PageIndexChanged">
            <Summary AllPagesText="<%$Resources:Strings, PagerText %>" Text="<%$Resources:Strings, PagerText %>" />
            <AllButton>
              <Image Height="19px" />
            </AllButton>
            <NextPageButton>
              <Image Height="19px" />
            </NextPageButton>
            <PrevPageButton>
              <Image Height="19px" />
            </PrevPageButton>
            <FirstPageButton>
              <Image Height="19px" />
            </FirstPageButton>
            <LastPageButton>
              <Image Height="19px" />
            </LastPageButton>
          </dxpg:ASPxPager>
        </div>
      </ContentTemplate>
      <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="pager" EventName="PageIndexChanged" />
      </Triggers>
    </asp:UpdatePanel>
  </div>
  <div style="clear: both; float: left; padding-top: 10px;">
    <dxe:ASPxButton ID="btnAdd" runat="server" Text="<%$ Resources:Strings, Add %>">
      <ClientSideEvents Click="function(s, e){onAdd();e.processOnServer = false;}" />
    </dxe:ASPxButton>
    <asp:XmlDataSource ID="xdsStatus" runat="server" XPath="Items/SearchNewsStatus/Status">
    </asp:XmlDataSource>
    <dxcb:ASPxCallback ID="ctrlCallback" ClientInstanceName="ctrlCallback" runat="server"
      OnCallback="ctrlCallback_Callback">
      <ClientSideEvents CallbackComplete="function(s,e){ctrlCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
    <asp:HiddenField ID="hfTypeId" runat="server" />
    <asp:HiddenField ID="hfCategoryId" runat="server" />
    <asp:XmlDataSource ID="xdsLanguage" runat="server" XPath="Items/LanguageSearch/Status">
    </asp:XmlDataSource>
  </div>

  <script type="text/javascript" language="javascript">
    function onAdd() {
      var typeId = document.getElementById('<%=hfTypeId.ClientID %>').value;
      var categoryId = document.getElementById('<%=hfCategoryId.ClientID %>').value;
      if (categoryId != '')
        window.location.href = 'NewsDetail.aspx?t=' + typeId + '&tid=' + categoryId;
      else window.location.href = 'NewsDetail.aspx?t=' + typeId;
      //window.location.href = 'NewsDetail.aspx';
    }

    function onDelete(id) {
      if (confirm('<%=(string)GetGlobalResourceObject("Messages", "ERR0006") %>'))
        ctrlCallback.SendCallback('Delete|' + id);
    }

    function ctrlCallback_CallbackComplete(s, e) {
      if (e.result != '') {
        alertMessage(e.result);
        return;
       }
      
      btnSearch.DoClick();
    }
  
  </script>

</asp:Content>
